//===============================================================================
// Microsoft patterns & practices
// Guidance Explorer Offline Client
//===============================================================================
// Copyright  Microsoft Corporation.  All rights reserved.
// THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY
// OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT
// LIMITED TO THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
// FITNESS FOR A PARTICULAR PURPOSE.
//===============================================================================

using System.Windows.Forms;
using GuidanceExplorer.Model;
using GuidanceExplorer.Model.Conditions;

namespace GuidanceExplorer.Controls
{
    //[MenuItemAttribute(500, "context\\New Item", GuidanceExplorer.Commands.NewGuidanceItem, typeof(ModelItemMenuItemIsEditableCondition), typeof(NewItemMenuItemProvider), Keys.None)]
    [MenuItemAttribute(520, "context\\Export Item as Xml...", "Export Items as Xml...", GuidanceExplorer.Commands.SaveItemAsXml, typeof(NotGenericMenuItemCondition<MenuItemUnderSolutionNodeCondition>), Keys.None)]
    [MenuItemAttribute(525, "context\\-", "", typeof(NotGenericMenuItemCondition<MenuItemUnderSolutionNodeCondition>), Keys.None)]
	[MenuItemAttribute(530, "context\\Add To View...", GuidanceExplorer.Commands.MoveGuidanceItemToView, typeof(NotGenericMenuItemCondition<MenuItemUnderSolutionNodeCondition>), Keys.None)]
	[MenuItemAttribute(540, "context\\-", "", typeof(NotGenericMenuItemCondition<MenuItemUnderSolutionNodeCondition>), Keys.None)]
    [MenuItemAttribute(550, "context\\Edit", GuidanceExplorer.Commands.EditGuidanceItem, typeof(ModelItemMenuItemIsEditableCondition), Keys.None)]
    [MenuItemAttribute(560, "context\\Delete", GuidanceExplorer.Commands.DeleteGuidanceItem, typeof(ModelItemMenuItemIsEditableCondition), Keys.None)]
    //[MenuItemAttribute(570, "context\\-", null, typeof(WebSubscribedLibraryCondition), Keys.None)]
    //[MenuItemAttribute(575, "context\\Synchronize Library", Commands.Synchronize, typeof(WebSubscribedLibraryCondition), Keys.None)]

    public class GuidanceItemNode : ModelNode<GuidanceExplorer.Model.GuidanceItemFileReference>
    {
        /// <summary>
        /// Factory.
        /// </summary>
        /// <returns></returns>
        public static GuidanceItemNode New()
        {
            return new GuidanceItemNode();
        }

        /// <summary>
        /// Default constructor.
        /// </summary>
        private GuidanceItemNode() : base("GuidanceItemNode", 9, 9) { }

        /// <summary>
        /// Whether the node can be dropped.
        /// </summary>
        public override bool CanDrop(IModelItem modelNode)
        {
            return false;
        }

        /// <summary>
        /// Whether the node is editable.
        /// </summary>
        public override bool IsEditable
        {
            get
            {
                return ModelInstance.IsEditable;
            }
        }

		/// <summary>
		/// Clone a GuidanceItemNode
		/// </summary>
		public GuidanceItemNode Clone(GuidanceItemFileReference newModelInstance)
		{
			GuidanceItemNode cloneNode = new GuidanceItemNode();

			cloneNode.Text = Text;
			if (newModelInstance == null)
			{
				cloneNode.ModelInstance = (GuidanceItemFileReference)ModelInstance.Clone();
			}
			else
			{
				cloneNode.ModelInstance = newModelInstance;
			}
			cloneNode.SelectedItem = SelectedItem;

			return cloneNode;
		}

    }
}

